home *** CD-ROM | disk | FTP | other *** search
- /*
- DefaultItem is a dialog user item procedure written using THINK C. This is a simple
- example of how to draw a default button outline with a user item. For best results,
- the user item should be disabled and it's display rectangle should surround the
- default button. The following code shows how the user item would typically be
- initialized.
-
- theDialog = GetNewDialog(DLOG_ID, NIL, -1);
- ...
- GetDItem(theDialog, USER_ITEM_NUM, &itemType, &itemHandle, &itemBox);
- SetDItem(theDialog, USER_ITEM_NUM, itemType, DefaultItem, &itemBox);
- ...
- ShowWindow(theDialog);
-
- © Lim Unlimited, 4 Mar 1991 - All Rights Reserved
- */
-
-
-
- /*
- header files
- */
-
- #include <Color.h>
- #include <ColorToolbox.h>
-
-
-
- /*
- constants and macros
- */
-
- #define NIL ((void *) 0)
-
- #define INACTIVE 255
-
- #define SYS_ENVIRONS_VERSION 1
-
- #define OUTLINE_THICKNESS 3
- #define OUTLINE_INSET (OUTLINE_THICKNESS + 1)
- #define OUTLINE_OUTSET (-OUTLINE_INSET)
- #define CURVE_ADJUSTMENT 2
-
-
-
- /*
- routines
- */
-
- pascal void DefaultItem (DialogPeek, short);
-
-
-
- /*
- DefaultItem draws an outline for the default button. The outline is drawn correctly
- for buttons of any size, color, and state.
- */
-
- pascal void DefaultItem(theDialog, itemNum)
-
- DialogPeek theDialog;
- short itemNum;
-
- {
- short itemType;
- ControlHandle theControl;
- Rect itemBox;
- SysEnvRec sysEnvirons;
- AuxCtlHndl auxCtlHdl;
- RGBColor oldColor, frameColor;
- PenState penState;
- short curvature;
-
- GetDItem(theDialog, theDialog->aDefItem, &itemType, &theControl, &itemBox);
-
- if (itemType == (ctrlItem | btnCtrl) && (*theControl)->contrlVis) {
- (void) SysEnvirons(SYS_ENVIRONS_VERSION, &sysEnvirons);
- if (sysEnvirons.hasColorQD) {
- (void) GetAuxCtl(theControl, &auxCtlHdl);
- GetForeColor(&oldColor);
- if (auxCtlHdl) {
- frameColor = (*(*auxCtlHdl)->acCTable)->ctTable[cFrameColor].rgb;
- RGBForeColor(&frameColor);
- }
- }
-
- GetPenState(&penState);
- PenNormal();
- PenSize(OUTLINE_THICKNESS, OUTLINE_THICKNESS);
- if ((*theControl)->contrlHilite == INACTIVE) {
- PenPat(&gray);
- }
- InsetRect(&itemBox, OUTLINE_OUTSET, OUTLINE_OUTSET);
- curvature = ((itemBox.bottom - itemBox.top) >> 1) + CURVE_ADJUSTMENT;
- FrameRoundRect(&itemBox, curvature, curvature);
- SetPenState(&penState);
-
- if (sysEnvirons.hasColorQD) {
- RGBForeColor(&oldColor);
- }
- }
- }
-